package Bidostar_Page;

import Bidostar_BaseData.Page;
import Bidostar_Data.Baseinfo;
import Bidostar_Data.Bidostar_GetCode;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class FeedBackPage extends Page
{

    public FeedBackPage(WebDriver driver)
    {
        super(driver);
    }

    public void clickFeedBack()
    {
        getElement("FeedBack").click();
    }

    public void InputFeedBackInfo(String FeedBackInfo)
    {
        getElement("FeedBackInfo").clear();
        getElement("FeedBackInfo").sendKeys(FeedBackInfo);
    }

    public void clickFeedBackBtn()
    {
        getElement("FeedBackBtn").click();
    }

    public void clickBackHome()
    {
        getElement("FeedBack_BackBtn").click();
    }

    public boolean FeedBack() throws Exception
    {
        try
        {
            clickFeedBack();
            logger.info(driver.findElement(By.id("feedbackInfo")).getAttribute("placeholder"));
            if (Baseinfo.FeedBackInfo.length() <= 0)
            {
                clickFeedBackBtn();
                logger.warn(getElement("FeedBack_Alert").getText());
                Thread.sleep(3000);
            } else if (Baseinfo.FeedBackInfo.length() > 0)
            {
                InputFeedBackInfo(Baseinfo.FeedBackInfo);
                logger.info("反馈内容：" + Baseinfo.FeedBackInfo);
                clickFeedBackBtn();
                clickBackHome();
            }
            if (Bidostar_GetCode.FeedBack_Info().equals(Baseinfo.FeedBackInfo) || getElement("FeedBack_BackBtn").isDisplayed())
            {
                logger.info("======反馈成功======");
                return true;
            }
        } catch (Exception e)
        {
            logger.warn("运行异常");
        }
        return false;
    }
}
